﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using ClassDAL;
using ClassModel;

namespace ClassBLL
{
    public class t_class_sections_BLL
    {
        /// <summary>
        /// 插入某个fileid -> excel 文件对应的上课节次设置
        /// </summary>
        /// <param name="sections"></param>
        /// <returns>-2表示一周节次设置和excel里一周节次数字不一致!</returns>
        public static int InsertSections(t_class_sections sections)
        {
            if (sections == null) throw new ArgumentException("sections is null");

            // 计算一周节次数量和老师排课数量是否一致。
            int lessionsCountInAWeek = (sections.AMSections + sections.PMSections) * sections.dayOfWeek;
            // excel表格里，一周体现的课程数
            int excelWeekSections = t_class_schedule_BLL.GetClassLessionCountInAWeek(sections.fileid);

            if (lessionsCountInAWeek != excelWeekSections) return -2;

            return t_class_sections_DAL.InsertSections(sections);
        }


        /// <summary>
        /// 检查当前excel对应的节次设置是否存存在
        /// </summary>
        /// <param name="taskID"></param>
        /// <returns></returns>
        public static bool CheckExistWithFileID(int taskID)
        {
            return t_class_sections_DAL.CheckExistWithFileID(taskID);
        }


        public static t_class_sections GetSectionByTaskID(int taskid)
        {
            return t_class_sections_DAL.GetSectionByTaskID(taskid);
        }
    }
}
